package com.sl.au.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.sl.au.entity.Account;
import com.sl.au.entity.EXDEPaymentNodeInfo;
import com.sl.au.entity.EXDEPaymentNodeInfoTQ;
import com.sl.au.service.EXDEPaymentNodeService;
/**
 * 应收账节点查询
 * @param zty
 * 2017-02-20
 */
@RestController
@RequestMapping(value="/ui/paymentNode")
public class PaymentNodeController extends BaseController{
	@Autowired
	EXDEPaymentNodeService<?, ?> exdePaymentNodeService;
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView modelAndView=createLayoutView("paymentSearch/paymentNode");
        Account a = this.getMyAccount();
      		String userId =a.getUser().getId();
      		modelAndView.addObject("userId",userId);
      		return modelAndView;
        
    }
    @RequestMapping(value = "/getMyTrance", method = RequestMethod.GET)
  	public Map<String,Object> getMyTrance(HttpServletRequest request) {
  		Map<String,Object> map = new HashMap<String,Object>();
  		@SuppressWarnings("unused")
		Map<String,String> condition = new HashMap<String,String>();
  		@SuppressWarnings("unused")
		Account a = this.getMyAccount();
  		String MonthYearDate = request.getParameter("MonthYearDate");//年月（字符串）
  		System.out.println(MonthYearDate);
  		String ReceivableTQDate = request.getParameter("ReceivableTQDate");//存储过程MonthAccountsReceivableTQ的时间
 		List<EXDEPaymentNodeInfo> users = null;//
 		users = exdePaymentNodeService.getMyPage(MonthYearDate);
 		
 		List<EXDEPaymentNodeInfoTQ> usersTQ = null;
 		usersTQ = exdePaymentNodeService.getMyPageTQ(ReceivableTQDate);
 		long count = users.size();
 		
 		map.put("users", users);
 		map.put("usersTQ", usersTQ);
  		map.put("draw", request.getParameter("draw"));
  		map.put("recordsFiltered", count);
  		map.put("recordsTotal", count);
  		return map;
  	}
}
